package com.milo;


import com.alibaba.fastjson.JSONObject;
import com.milo.outxml.AlipayXmlOutMessage;
import com.milo.xml.AlipayXmlMessage;
import com.milo.xml.SkyXmlMessage;

import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;

/**
 * 常用注解
 * <p>
 * @XStreamAlias("message") ����ע��  ����Ŀ��: ��,�ֶ�
 * @XStreamImplicit ��ʽ����
 * @XStreamImplicit(itemFieldName="part") ����Ŀ��: �����ֶ�
 * @XStreamConverter(SingleValueCalendarConverter.class) ע��ת����  ����Ŀ��: ����
 * @XStreamAsAttribute ת��������  ����Ŀ��: �ֶ�
 * @XStreamOmitField �����ֶ�  ����Ŀ��: �ֶ�
 * </p>
 * @author milogenius
 * @date 2020-04-03 15:49
 */
public class XmlDemoTest {

    public static void main(String[] args) throws UnsupportedEncodingException {
        //xml --->pojo
        String bizContent = "<XML>\n" +
                "    <AppId><![CDATA[2014070100171523]]></AppId>\n" +
                "    <FromUserId><![CDATA[20882837462837462837462837461234]]></FromUserId>\n" +
                "    <FromAlipayUserId><![CDATA[2088283746283746]]></FromAlipayUserId>\n" +
                "    <CreateTime><![CDATA[1405943673657]]></CreateTime>\n" +
                "    <MsgType><![CDATA[event]]></MsgType>\n" +
                "    <EventType><![CDATA[follow]]></EventType>\n" +
                "    <ActionParam><![CDATA[{\"scene\":{\"sceneId\": \"1234\"}}]]></ActionParam>\n" +
                "    <AgreementId><![CDATA[]]></AgreementId>\n" +
                "    <AccountNo><![CDATA[]]></AccountNo>\n" +
                "    <UserInfo><![CDATA[{\"logon_id\":\"135****1009\",\"user_name\":\"*iuxu527\"}]]></UserInfo>\n" +
                "</XML>";
        //AlipayXmlMessage alipayXmlMessage = AlipayXmlMessage.fromXml(bizContent);
       //System.out.println(alipayXmlMessage);

        String skyXMl = "<dingxi dn=\"day\">\n" +
                "    <city cityX=\"219\" cityY=\"170\" cityname=\"临洮县\" centername=\"临洮县\" fontColor=\"FFFFFF\" pyName=\"\" state1=\"2\" state2=\"2\" stateDetailed=\"阴\" tem1=\"14\" tem2=\"2\" temNow=\"15\" windState=\"东风3-4级\" windDir=\"东风\" windPower=\"3级\" humidity=\"21%\" time=\"15:00\" url=\"101160205\"/>\n" +
                "    <city cityX=\"256\" cityY=\"231\" cityname=\"渭源县\" centername=\"渭源县\" fontColor=\"FFFFFF\" pyName=\"\" state1=\"2\" state2=\"2\" stateDetailed=\"阴\" tem1=\"13\" tem2=\"2\" temNow=\"11\" windState=\"小于\" windDir=\"东风\" windPower=\"2级\" humidity=\"23%\" time=\"15:00\" url=\"101160204\"/>\n" +
                "    <city cityX=\"324\" cityY=\"141\" cityname=\"定西市\" centername=\"定西市\" fontColor=\"FFFF00\" pyName=\"\" state1=\"2\" state2=\"2\" stateDetailed=\"阴\" tem1=\"10\" tem2=\"1\" temNow=\"7\" windState=\"小于\" windDir=\"东风\" windPower=\"3级\" humidity=\"51%\" time=\"15:00\" url=\"101160201\"/>\n" +
                "    <city cityX=\"325\" cityY=\"244\" cityname=\"陇西县\" centername=\"陇西县\" fontColor=\"FFFFFF\" pyName=\"\" state1=\"2\" state2=\"2\" stateDetailed=\"阴\" tem1=\"14\" tem2=\"3\" temNow=\"11\" windState=\"小于\" windDir=\"东北风\" windPower=\"2级\" humidity=\"28%\" time=\"15:00\" url=\"101160203\"/>\n" +
                "    <city cityX=\"417\" cityY=\"211\" cityname=\"通渭县\" centername=\"通渭县\" fontColor=\"FFFFFF\" pyName=\"\" state1=\"2\" state2=\"2\" stateDetailed=\"阴\" tem1=\"14\" tem2=\"2\" temNow=\"9\" windState=\"小于\" windDir=\"东北风\" windPower=\"3级\" humidity=\"48%\" time=\"15:00\" url=\"101160202\"/>\n" +
                "    <city cityX=\"287\" cityY=\"307\" cityname=\"漳县\" centername=\"漳县\" fontColor=\"FFFFFF\" pyName=\"\" state1=\"2\" state2=\"2\" stateDetailed=\"阴\" tem1=\"13\" tem2=\"1\" temNow=\"11\" windState=\"小于\" windDir=\"东风\" windPower=\"3级\" humidity=\"20%\" time=\"15:00\" url=\"101160206\"/>\n" +
                "    <city cityX=\"216\" cityY=\"394\" cityname=\"岷县\" centername=\"岷县\" fontColor=\"FFFFFF\" pyName=\"\" state1=\"2\" state2=\"2\" stateDetailed=\"阴\" tem1=\"12\" tem2=\"2\" temNow=\"11\" windState=\"小于\" windDir=\"东风\" windPower=\"2级\" humidity=\"27%\" time=\"15:00\" url=\"101160207\"/>\n" +
                "</dingxi>";

        SkyXmlMessage skyXmlMessage = SkyXmlMessage.fromXml(skyXMl);
        skyXmlMessage.getCity().forEach(i->{
            System.out.println(i.toString());
        });

        //pojo --->xml
     /*   AlipayXmlOutMessage mpXmlOutMessage = AlipayXmlOutMessage.ACK().toUserId("123456").appId("99999999").build();
        String xml = mpXmlOutMessage.toXml();
        System.out.println(xml);*/

    }
}
